package yzbx.personalwebsite.tool;

import com.alibaba.fastjson2.JSONObject;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

/**
 * {@code @Author} zxm
 * {@code @Description} 调用第三方接口
 * {@code @Date} 2024/09/30/10:00
 * {@code @Version} 1.0
 */
@Component
public class Httptool {

    public JSONObject doGet(String url) {
        RestTemplate restTemplate = new RestTemplate();
        Map<String, String> params = new HashMap<String, String>();
        HttpHeaders headers = new HttpHeaders();
        HttpEntity<Object> entity = new HttpEntity<>(params, headers);
        return restTemplate.exchange(url, HttpMethod.GET, entity, JSONObject.class).getBody();
    }
}
